package com.example.springbootdemo.webapi;

import com.example.springbootdemo.entity.UserCase;
import com.example.springbootdemo.service.UserCaseService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Gong.Yang
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/user_case")
public class UserCaseApi {
    private final UserCaseService userCaseService;

    @GetMapping("/list")
    public List<UserCase> findList() {
        return userCaseService.findList();
    }

    @GetMapping("/item/{id}")
    public UserCase findItem(@PathVariable String id) {
        return userCaseService.findItem(id);
    }

    @PostMapping
    public UserCase create(@RequestBody UserCase userCase) {
        return userCaseService.create(userCase);
    }

    @PutMapping
    public UserCase modify(@RequestBody UserCase userCase) {
        return userCaseService.modify(userCase);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable String id) {
        userCaseService.delete(id);
    }

}
